package com.app.biz.service.impl;

import com.app.biz.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IndexServiceImpl implements IndexService {

    /**
     *  重点地区工业增加值 */
    @Autowired
    private IBizKeyAreasValuesService bizKeyAreasValuesService;

    /**
     * 重点地区产销率同比
     */
    @Autowired
    private IBizProduceSaleService bizProduceSaleService;

    /**
     * 分行业增加值同比
     */
    @Autowired
    private IBizIndustryAddedService bizIndustryAddedService;

    /**
     * 分市工业增加值同比
     */
    @Autowired
    private IBizIndustrialValueAddedByCityService bizIndustrialValueAddedByCityService;

    /**
     * 重点调度产品产量
     */
    @Autowired
    private IBizFocusSchedulingProductProductionService bizFocusSchedulingProductProductionService;

    /**
     * 分市工业企业主要经济
     */
    @Autowired
    private IBizCityIndustrialEconomicsService bizCityIndustrialEconomicsService;

    /**
     * 分行业工业企业主要经济
     */
    @Autowired
    private  IBizIndustrialSectorMetricsService bizIndustrialSectorMetricsService;
    /**
     * 山东与全国制造采购
     */
    @Autowired
    private IBizManufacturingPmiComparisonService bizManufacturingPmiComparisonService;


    /**
     * 山东制造业PMI一览表
     */
    @Autowired
    private IBizPmiService bizPmiService;

    /**
     * 全社会天线情况
     */
    @Autowired
    private IBizSocialElectricityConsumptionService bizSocialElectricityConsumptionService;

    /**
     * 工业用电量
     */
    @Autowired
    private IBizPowerConsumptionService bizPowerConsumptionService;

    /**
     * @return
     */
    @Override
    public Map<String, Object> getIndexMenu() {

        Map<String,Object> result = new HashMap<>(16);
        /* 重点地区工业增加值 */
        List<String> uniqueDatesFromDatabase = bizKeyAreasValuesService.getUniqueDatesFromDatabase();
        if(!uniqueDatesFromDatabase.isEmpty()){
            result.put("zddqgyzjz",uniqueDatesFromDatabase.get(0));
        }else{
            result.put("zddqgyzjz","无数据");
        }
        /* 重点地区产销率同比 */
        List<String> zddqcxltbList = bizProduceSaleService.getUniqueDatesFromDatabase();
        if(!zddqcxltbList.isEmpty()){
            result.put("zddqcxltb",zddqcxltbList.get(0));
        }else{
            result.put("zddqcxltb","无数据");
        }
        /* 分市工业增加值同比 */
        List<String> fzgyzjztb = bizIndustrialValueAddedByCityService.getUniqueDatesFromDatabase();
        if(!fzgyzjztb.isEmpty()){
            result.put("fzgyzjztb",fzgyzjztb.get(0));
        }else{
            result.put("fzgyzjztb","无数据");
        }

        /* 分行业增加值同比 */
        List<String> zhyzjztb = bizIndustryAddedService.getUniqueDatesFromDatabase();
        if(!zhyzjztb.isEmpty()){
            result.put("zhyzjztb",zhyzjztb.get(0));
        }else{
            result.put("zhyzjztb","无数据");
        }
        /* 重点调度产品产量 */
        List<String> zddycpcl = bizFocusSchedulingProductProductionService.getUniqueDatesFromDatabase();
        if(!zddycpcl.isEmpty()){
            result.put("zddycpcl",zddycpcl.get(0));
        }else{
            result.put("zddycpcl","无数据");
        }

        /* 分市工业企业主要经济 */
        List<String> fsgyqyzyjj = bizCityIndustrialEconomicsService.getUniqueDatesFromDatabase();
        if(!fsgyqyzyjj.isEmpty()){
            result.put("fsgyqyzyjj",fsgyqyzyjj.get(0));
        }else{
            result.put("fsgyqyzyjj","无数据");
        }

        List<String> sdyqgzzycg = bizManufacturingPmiComparisonService.getUniqueDatesFromDatabase();
        if(!sdyqgzzycg.isEmpty()){
            result.put("sdyqgzzycg",sdyqgzzycg.get(0));
        }else{
            result.put("sdyqgzzycg","无数据");
        }
        List<String> sdzzypmi = bizPmiService.getUniqueDatesFromDatabase();
        if(!sdzzypmi.isEmpty()){
            result.put("sdzzypmi",sdzzypmi.get(0));
        }else{
            result.put("sdzzypmi","无数据");
        }
        List<String> qshydlqk = bizSocialElectricityConsumptionService.getUniqueDatesFromDatabase();
        if(!qshydlqk.isEmpty()){
            result.put("qshydlqk",qshydlqk.get(0));
        }else{
            result.put("qshydlqk","无数据");
        }

        List<String> gyydlqk = bizPowerConsumptionService.getUniqueDatesFromDatabase();
        if(!gyydlqk.isEmpty()){
            result.put("gyydlqk",gyydlqk.get(0));
        }else{
            result.put("gyydlqk","无数据");
        }

        /* 分行业工业企业主要经济指标 */
        List<String> fhygyqyzyjj = bizIndustrialSectorMetricsService.getUniqueDatesFromDatabase();
        if(!fhygyqyzyjj.isEmpty()){
            result.put("fhygyqyzyjj",fhygyqyzyjj.get(0));
        }else{
            result.put("fhygyqyzyjj","无数据");
        }
        return result;
    }
}
